import service from "@/utils/request"

import LoginWork from "@/utils/LoginWork"

// 待入库明细查询
export const QueryDetailsToBeStored = () => {
    return service.get<any, any>(`/pcFactorStockQuery/getCsmInTempQuery`)
}
export const JianQueryDetailsToBeStored = () => {
    return service.get<any, any>(`/product/sdmaterial/sdMaterialList`)
}
// 入库明细查询
export interface QueryTheStorageDetailsParms {
    lotNo: string,
    mtlName: string,
    sendNo: string,
    slipDateEnd: string,
    slipDateStart: string,
    slipNo: string,
    slipReason: string,
    sysDateEnd: string,
    sysDateStart: string
    vendorNo: string
}

export const QueryTheStorageDetails = (parms: QueryTheStorageDetailsParms) => {
    return service.put<any, any>(`/pcFactorStockQuery/getCsmInDetailQuery`, parms)
}
export const JianQueryTheStorageDetails = (parms: QueryTheStorageDetailsParms) => {
    return service.post<any, any>(`/product/sdmaterial/pcSlipDetailPartList`, parms)
}
// 部门
export const GainDeptNmae = () => {
    return service.get<any, any>(`/back/deptQuery`)
}

// 厂商
export const GainVendor = () => {
    return service.get<any, any>(`/back/vendorQuery`)
}

// 分类
export const GainClassification = () => {
    return service.get<any, any>(`/back/getMtrTypeQuery`)
}

// 选择材料查询
export interface SelectMaterialQueryInterface {
    dtos: dtosList[],
    total?: number
}

interface dtosList {
    mtlNo: string,
    mtlName: string,
    typeName: string,
    mtlUnit: string
}

export const SelectMaterialQuery = (mtlName: string, type: string, parms: any) => {
    return service.put<any, SelectMaterialQueryInterface>(`/back/getMtrQuery?mtlName=${mtlName}&type=${type}`, parms)
}
export const JianSelectMaterialQuery = (parms: any) => {
    return service.post<any, SelectMaterialQueryInterface>(`/product/sdmaterial/outMaterialList`, parms)
}
// 待入库明细新增
export const DetailsToBeStoredAreAdded = (mtlNo: string) => {
    return LoginWork.post<any, any>(`/pcFactorStockQuery/csmInTempAdd?mtlNo=${mtlNo}`)
}
export const JianDetailsToBeStoredAreAdded = (mtlNo: string) => {
    return LoginWork.get<any, any>(`/product/sdmaterial/insertMaterialPart?mtlNo=${mtlNo}`)
}
// 选择材料删除
export const MaterialDeletion = (mtlNo: string) => {
    return LoginWork.post<any, any>(`/pcFactorStockQuery/csmMtlDelete?mtlNo=${mtlNo}`)
}
export const JianMaterialDeletion = (mtlNo: string) => {
    return LoginWork.post<any, any>(`/product/sdmaterial/deletePcSlipDetailPart?mtlNo=${mtlNo}`)
}

// 生成物料编码
export const GeneratedMaterialCoding = (mtlTypeNo: string) => {
    return LoginWork.post<any, any>(`/pcFactorStockQuery/csmMtlNoCreat?mtlTypeNo=${mtlTypeNo}`)
}

// 选择材料新增
export interface SelectMaterialNewPamrs {
    mtlColor: string,
    mtlName: string,
    mtlNo: string,
    mtlSpec: string,
    mtlUnit: string,
    typeName: string,
    typeNo: string
}

export const SelectMaterialNew = (parms: SelectMaterialNewPamrs) => {
    return LoginWork.put<any, any>(`/pcFactorStockQuery/csmMtlCreat`, parms)
}

// 待入库删除
export const ToBeDeleted = (mtlNo: string) => {
    return LoginWork.post<any, any>(`/pcFactorStockQuery/csmInTempDelete?mtlNo=${mtlNo}`)
}
export const JianToBeDeleted = (mtlNo: string) => {
    return LoginWork.post<any, any>(`/product/sdmaterial/deletePcSlipDetailPart?mtlNo=${mtlNo}`)
}
// 入库明细资料新增
export interface StorageDetailsAddedParms {
    deptName: string,
    deptNo: string,
    mtlNo: string,
    sendNo: string,
    slipDate: string,
    slipReason: string,
    sysDate: string,
    vendorName: string,
    vendorNo: string
}

export const StorageDetailsAdded = (parms: StorageDetailsAddedParms) => {
    return LoginWork.put<any, any>('/pcFactorStockQuery/csmInDetailAdd', parms)
}
export const JianStorageDetailsAdded = (parms: StorageDetailsAddedParms) => {
    return LoginWork.post<any, any>('/product/sdmaterial/insertBatchPcPart', parms)
}

// 入库明细删除
export const deleteRow = (mtlNo:string,slipNo:string) => {
    return LoginWork.post<any,any>(`/pcFactorStockQuery/csmInDetailDelete?mtlNo=${mtlNo}&slipNo=${slipNo}`)
}